//
//  Project_ElectCheckSumModel.m
//  he_Lan
//
//  Created by xyyl on 2021/6/22.
//  Copyright © 2021 xyyl. All rights reserved.
//

#import "Project_ElectCheckSumModel.h"
#import "NSString+BluseStr.h"

@implementation Project_ElectCheckSumModel

- (BOOL)caculaterFinalStr {
    if (_head.length == 0 || _lenth.length == 0 || self.cmd.length == 0 || _end.length == 0) {
        return NO;
    }
    
    NSMutableArray * mu = [NSMutableArray new];
    [mu addObjectsFromArray:_data];
//    [mu insertObject:_channel atIndex:0];
    [mu insertObject:self.cmd atIndex:0];

    _checkSum = [NSString hexadecimaAddWithHexadecimaArray:mu];
    
    NSMutableString * finlll = [[NSMutableString alloc]init];
    [finlll appendFormat:@"%@",_head];
    [finlll appendFormat:@"%@",_lenth];
    [finlll appendFormat:@"%@",self.cmd];
//    [finlll appendFormat:@"%@",_channel];
    for (NSString * str  in _data) {
        [finlll appendFormat:@"%@",str];

    }
    [finlll appendFormat:@"%@",_checkSum];
    [finlll appendFormat:@"%@",_end];
    _finnalStr = [NSString stringWithFormat:@"%@",finlll];
    return YES;
}


@end
